package options;

import gui.OptionsTest;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

/**
 * Optionen zum Kalender
 * 
 * @author Michi
 * 
 */
public class KalenderOptionPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3696722333819038571L;
	private JRadioButton radioMonatsansicht;
	private JRadioButton radioWochenansicht;
	private JLabel dummyLabel;
	private String[] windowColorsSeperated;
	private JLabel dummyLabel1;
	private JLabel dummyLabel2;
	private JLabel infoLabel;
	private JLabel dummyLabel3;

	// Sprache
	int speak = 0;
	String[] monatsA = { "Monatsansicht", "Month View", "Camp Totus" };
	String[] wochenA = { "Wochenansicht", "Week View", "Hebdomadatim" };
	String[] standard = { "Standartkalenderansicht", "Default View",
			"Vexillum Calendarium Visum" };
	String[] aenderungen = {
			"\u00C4nderungen werden nach einem Programmneustart \u00FCbernommen.",
			"Changes are applied after a program restart.",
			"Mutationes applicantur satus progressio." };

	/**
	 * Create the panel.
	 */
	public KalenderOptionPanel(final OptionsTest optionsTestInstance) {
		speak = Integer.parseInt(optionsTestInstance.getOr().getLanguage());

		String windowColors = optionsTestInstance.getOr().getColorSetting();
		windowColorsSeperated = windowColors.split(",");
		setBackground(new Color(Integer.parseInt(windowColorsSeperated[0]),
				Integer.parseInt(windowColorsSeperated[1]),
				Integer.parseInt(windowColorsSeperated[2])));
		setMinimumSize(new Dimension(600, 700));
		setMaximumSize(new Dimension(600, 700));
		setPreferredSize(new Dimension(600, 700));
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
		gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0, 0 };
		gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0,
				0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
		gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
				0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
				Double.MIN_VALUE };
		setLayout(gridBagLayout);

		JLabel labelSprache = new JLabel(standard[speak]);
		labelSprache.setFont(new Font("Lucida Grande", Font.BOLD, 13));
		GridBagConstraints gbc_labelSprache = new GridBagConstraints();
		gbc_labelSprache.gridwidth = 2;
		gbc_labelSprache.anchor = GridBagConstraints.WEST;
		gbc_labelSprache.insets = new Insets(0, 0, 5, 5);
		gbc_labelSprache.gridx = 1;
		gbc_labelSprache.gridy = 1;
		add(labelSprache, gbc_labelSprache);

		radioWochenansicht = new JRadioButton(wochenA[speak]);
		radioWochenansicht.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				radioWochenansicht.setSelected(true);
				radioMonatsansicht.setSelected(false);
				optionsTestInstance.setCalOptStandardView("week");
				infoLabel.setVisible(true);
			}
		});

		radioMonatsansicht = new JRadioButton(monatsA[speak]);
		radioMonatsansicht.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				radioWochenansicht.setSelected(false);
				radioMonatsansicht.setSelected(true);
				optionsTestInstance.setCalOptStandardView("month");
				infoLabel.setVisible(true);

			}
		});

		dummyLabel = new JLabel("   ");
		dummyLabel.setPreferredSize(new Dimension(12, 25));
		GridBagConstraints gbc_dummyLabel = new GridBagConstraints();
		gbc_dummyLabel.insets = new Insets(0, 0, 5, 5);
		gbc_dummyLabel.gridx = 1;
		gbc_dummyLabel.gridy = 2;
		add(dummyLabel, gbc_dummyLabel);
		GridBagConstraints gbc_radioMonatsansicht = new GridBagConstraints();
		gbc_radioMonatsansicht.insets = new Insets(0, 0, 5, 5);
		gbc_radioMonatsansicht.gridx = 2;
		gbc_radioMonatsansicht.gridy = 3;
		add(radioMonatsansicht, gbc_radioMonatsansicht);
		GridBagConstraints gbc_radioWochenansicht = new GridBagConstraints();
		gbc_radioWochenansicht.insets = new Insets(0, 0, 5, 5);
		gbc_radioWochenansicht.gridx = 4;
		gbc_radioWochenansicht.gridy = 3;
		add(radioWochenansicht, gbc_radioWochenansicht);

		dummyLabel1 = new JLabel("   ");
		dummyLabel1.setPreferredSize(new Dimension(12, 25));
		GridBagConstraints gbc_dummyLabel1 = new GridBagConstraints();
		gbc_dummyLabel1.insets = new Insets(0, 0, 5, 5);
		gbc_dummyLabel1.gridx = 1;
		gbc_dummyLabel1.gridy = 4;
		add(dummyLabel1, gbc_dummyLabel1);

		infoLabel = new JLabel(aenderungen[speak]);
		infoLabel.setVisible(false);
		GridBagConstraints gbc_infoLabel = new GridBagConstraints();
		gbc_infoLabel.anchor = GridBagConstraints.WEST;
		gbc_infoLabel.gridwidth = 8;
		gbc_infoLabel.insets = new Insets(0, 0, 5, 0);
		gbc_infoLabel.gridx = 1;
		gbc_infoLabel.gridy = 5;
		add(infoLabel, gbc_infoLabel);

		dummyLabel2 = new JLabel("   ");
		GridBagConstraints gbc_dummyLabel2 = new GridBagConstraints();
		gbc_dummyLabel2.insets = new Insets(0, 0, 5, 5);
		gbc_dummyLabel2.gridx = 1;
		gbc_dummyLabel2.gridy = 6;
		add(dummyLabel2, gbc_dummyLabel2);

		dummyLabel3 = new JLabel("   ");
		dummyLabel3.setPreferredSize(new Dimension(12, 25));
		GridBagConstraints gbc_dummyLabel3 = new GridBagConstraints();
		gbc_dummyLabel3.insets = new Insets(0, 0, 5, 5);
		gbc_dummyLabel3.gridx = 1;
		gbc_dummyLabel3.gridy = 8;
		add(dummyLabel3, gbc_dummyLabel3);

		if (optionsTestInstance.getCalOptStandardView().equals("week")) {
			radioWochenansicht.setSelected(true);
		} else if (optionsTestInstance.getCalOptStandardView().equals("month")) {
			radioMonatsansicht.setSelected(true);
		} else {
			radioWochenansicht.setSelected(true);
		}

	}

	public void forceRepaint() {
		paint(getGraphics());
	}

	public JRadioButton getRdbtnEnglisch() {
		return radioMonatsansicht;
	}

	public void setRdbtnEnglisch(JRadioButton rdbtnEnglisch) {
		this.radioMonatsansicht = rdbtnEnglisch;
	}

	public JRadioButton getRdbtnDeutsch() {
		return radioWochenansicht;
	}

	public void setRdbtnDeutsch(JRadioButton rdbtnDeutsch) {
		this.radioWochenansicht = rdbtnDeutsch;
	}

}
